home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ KopyRong (K) 1987. ALL RIGHTS REVERSED. */
- /* */
- /* */
- /* This module was written by Vince Perriello */
- /* (based heavily on a similar work by Wynn Wagner III) */
- /* with modifications done by Bob Hartman */
- /* */
- /* */
- /* BinkleyTerm Mail Session Initiator */
- /* */
- /* This software package is being distributed WITH FULL SOURCE CODE */
- /* with the following conditions: 1) If anything awful happens */
- /* because you use it (or don't use it), you accept full */
- /* responsibility; 2) you don't start making tons of voice calls to */
- /* the authors to complain or make suggestions about enhancements, */
- /* useful or otherwise; 3) you do not reuse this code in commercial */
- /* products without specific permission to do so from the authors; */
- /* 4) If you find any problems you send fixes to the authors for */
- /* inclusion in updates; 5) You find some way to express your */
- /* appreciation for this method of distribution, either by writing */
- /* code or application notes, or just sending along a "Thank You" */
- /* message. */
- /* */
- /* There is copyrighted code in this product. We either wrote it */
- /* ourselves or got permission to use it. Please don't force us to */
- /* pay a lawyer -- have some respect for our motives and don't abuse */
- /* this "license". */
- /* */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
-
- #define WAZOO_SECTION
- #define MATRIX_SECTION
-
- #include "com.h"
- #include "xfer.h"
-
- extern char BBSwelcome[];
-
- int opus_maj;
- int opus_min;
- int got_arcmail;
- int got_bundle;
- int got_mail;
- int sent_mail;
- int remote_zone;
- int remote_net;
- int remote_node;
- int remote_point;
- int remote_capabilities;
- char *remote_sysop = " ";
- char *remote_password;
- extern int mail_only;
- extern int hup;
- extern int boss_net, boss_node;
- extern int BBStimeout;
- extern int cur_event;
- extern int un_attended;
- extern int fullscreen;
- extern char *BBSbanner;
- char *BBSesc = "\rPress ESCape to enter BBS.\r";
- char *noBBS = "\r\rProcessing Mail. Please hang up.\r\r";
- char no_pickup = 0;
-
- b_session(was_initiator)
- int was_initiator;
- {
- long t1,t2,t3,timerset();
- unsigned char i, j, d;
- char *c;
- char buff[128];
-
- if (un_attended && fullscreen)
- {
- gotoxy (69, 7);
- cprintf ("%-2d Connect", cur_event + 1);
- }
-
- /* Remove the old .REQ files */
- for (i = 0; i < 10; i++)
- {
- if (ctl.alias[i].net == 0)
- break;
- sprintf( buff, "%s%04x%04x.REQ", ctl.filepath,ctl.alias[i].net,ctl.alias[i].node);
- unlink (buff);
- }
-
- remote_capabilities = 0;
- if (was_initiator) goto initiate_outbound;
- /*
- * INBOUND -- meaning we were connected to by another system.
- */
- initiate_inbound:
- /* First a five second delay, or a char is found */
- t2 = timerset (500);
- i = 0;
-
- /* As long as we have carrier, and 5 seconds is not up, and no */
- /* special chars have been received, just continue looping */
- while (CARRIER && (!timeup(t2)) && (i == 0))
- {
- if ((i = PEEKBYTE()) >= 0)
- {
- switch (i&0x7f)
- {
- case CR:
- case LV:
- case ' ':
- case TSYNC:
- case YOOHOO:
- case ENQ:
- case ESC:
- continue;
- default:
- TIMED_READ(0);
- }
- }
- i = 0;
- }
-
- sprintf (buff, "\r\r* Network Address %d:%d/%d.%d Using %s",
- ctl.our_zone, boss_net, boss_node,
- (boss_net == ctl.alias[0].net) ? 0 : ctl.alias[0].node, ANNOUNCE);
- c = buff;
-
- SENDCHARS (c, strlen (c), 1);
-
- t2 = timerset (BBStimeout); /* 20 second timeout */
-
- if (strlen(BBSbanner) != 0) /* If BBS name spec'ed, */
- {
- SENDBYTE('\r'); /* make sure user gets */
- SENDBYTE('\n'); /* a full cr/lf... */
-
- c = BBSbanner; /* use BBS name */
-
- SENDCHARS (c, strlen (c), 1);
-
- SENDBYTE('\r'); /* make sure user gets */
- SENDBYTE('\n'); /* a full cr/lf... */
- }
-
- if (!mail_only)
- {
- c = BBSwelcome;
- while (*c && CARRIER)
- {
- /* Are we at the EOF? */
- if (*c == 0x1a)
- break;
-
- SENDBYTE (*c);
- ++c;
- }
- }
-
- play_banner:
- if (mail_only) /* If no BBS allowed, */
- c = noBBS; /* tell human to git */
- else
- c = BBSesc; /* or hit ESC for BBS */
-
- SENDCHARS (c, strlen (c), 1);
-
- get_handshake:
- while (CARRIER && (!timeup(t2)))
- {
- i = PEEKBYTE()&0xff; /* Get the next char */
- switch (i)
- {
- case 0xff: /* No character there */
- continue;
-
- case YOOHOO: /* Looks like an Opus */
- got_a_yoohoo:
- if (get_YOOHOO(1)) /* Get its HELLO string */
- return(WaZOO(0)); /* And do WaZOO!!! */
- else if (!hup)
- goto get_handshake; /* bad hello, try again */
- else return;
-
- case TSYNC: /* Looks like an FTSC */
- /* Here we should probably really see if it is an FTSC */
- /* See if we get anything within 2 seconds, if not, then it */
- /* is FTSC. If we get another TSYNC, it also means FTSC. */
- /* BUT, if we get a YOOHOO, then we can do WaZOO, and it */
- /* just means that we missed the first YOOHOO - lucky us. */
- CLEAR_INBOUND ();
- t3 = timerset (200); /* Set for 2 seconds */
- d = 0;
- while (CARRIER && (!timeup (t3)) && (!d))
- {
- if ((i = PEEKBYTE()) >= 0)
- {
- switch (i)
- {
- case YOOHOO:
- goto got_a_yoohoo;
-
- case TSYNC:
- d = 1;
- break;
-
- default:
- TIMED_READ(0);
- }
- }
- }
- if (CARRIER)
- return (FTSC_receiver(0));
- else
- return (1);
-
- case CR:
- i = TIMED_READ(0); /* Eat the CR */
- goto play_banner; /* Play the banner again*/
-
- case ESC: /* This will be for BBS */
- if (!mail_only) /* If BBS operation OK, */
- goto spawnBBS; /* go do it... */
-
- default:
- i = TIMED_READ (0); /* Eat the character */
- }
- }
- spawnBBS:
- if (CARRIER && !mail_only)
- BBSexit();
- return;
-
- /*
- * OUTBOUND -- meaning call was made by us.
- */
-
- initiate_outbound:
-
- if (FTSC_Whack_CR())
- {
- return (-1);
- }
- t1 = timerset(3000); /* set 30 second timeout */
- j = 0;
- while (!timeup(t1) && CARRIER) /* till then or CD lost */
- {
- SENDBYTE(YOOHOO); /* Initiate session? */
- SENDBYTE(TSYNC);
-
- t2 = timerset (300);
- while (CARRIER && (!timeup(t2)))
- {
- i = TIMED_READ (0);
-
- /* Because Fido v12 has a tendency to echo the YooHoo and throw */
- /* off the value of j which we use later on. We just ignore it */
- if ((i&0x7f) == (YOOHOO&0x7f))
- continue;
-
- switch (i)
- {
- case ENQ:
- if (send_YOOHOO(1)) /* Send Hello packet, */
- return(WaZOO(1)); /* do WaZOO and leave */
- else
- return(-1);
- break;
-
- case 0x00:
- case 0x01:
- case 'C':
- if (j == 'C')
- return (FTSC_sender(0));
- break;
-
- case 0xfe:
- case 0xfffe:
- if (j == 0x01)
- return (FTSC_sender(0));
- break;
-
- case 0xff:
- case 0xffff:
- if (j == 0x00)
- return (FTSC_sender(0));
- break;
-
- case NAK:
- if (j == NAK)
- return (FTSC_sender(0));
- break;
- }
- if ((i != 0xffff) && (i != 0xff))
- j = i;
- }
- }
- }
-
- b_init()
- {
- opus_maj = opus_min = got_arcmail = got_bundle = got_mail = sent_mail = 0;
- remote_zone = remote_net = remote_node = remote_point = 0;
- remote_capabilities = 0;
- }